﻿// Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once
#include <chrono>
#include <iomanip>
#include <iostream>
#include <ostream>
#include <stdlib.h>
#include <vector>

#include <algorithm>
#include <cstring>
#include <fstream>
#include <numeric>
#include <opencv2/opencv.hpp>
#include <spdlog/spdlog.h>
#include "model_struct.h"

namespace ai {


std::vector<std::string> ReadDict(const std::string &path);


void GetRotateCropImage(const cv::Mat srcimage,
    std::vector<cv::Point> four_points,
    cv::Mat &crop_image); 


// Visualiztion Detection Result
cv::Mat draw_det_box(cv::Mat& img,
                    const std::vector<DetInfo>& results,
                    const std::vector<std::string>& lable_list,
                    const std::vector<int>& colormap);

void visualize_db( cv::Mat& srcimg,
                      cv::Mat &save_image,
                      std::vector <BaseInfo*> &text_lines,
                      bool save_img);


// Generate visualization colormap for each class
std::vector<int> GenerateColorMap(int num_class);

cv::Mat visualize(const cv::Mat& img,
                  std::vector<BaseInfo*>& det_infos,
                  const std::vector<std::string>& labels);

template<class Type>
void log_tensor_shape(const std::string& name, std::vector<Type> data) {
    std::string out_str =  name + ": [";
    for (const auto& n : data) { out_str += std::to_string(n) + ", "; }
    spdlog::get("logger")->info("{}]", out_str);
}
void log_tensor_shape(const std::string& name, std::vector<std::string> data);

} // namespace paddle_infer
